<?php


//通示小区查询房号楼号
namespace App\Http\Controllers\Property;


use App\Common\json;
use App\Common\SmsClient;
use App\Http\Controllers\Controller;
use App\Libraries\upload;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class VillageController extends Controller{

    public function villagelike(Request $request){
        if($request ->isMethod('post')){
            $village_id        = $request ->input('village_id');
            $value             = $request ->input('value');
            $data              = DB::table('village_rooms')
                               ->where('rooms_village',$village_id)

                               ->where('room_name', 'like','%'.$value.'%')
                               ->get();
            foreach ($data as $value){
                $rooms_id     = $value ->rooms_id;
                $rooms_village  = $value ->rooms_village;
                $room_name      = $value ->room_name;
                $da[]             = array(
                    'rooms_id'   =>$rooms_id,
                    'rooms_village'=>$rooms_village,
                    'room_name'=>$room_name
                );
            }
            if(empty($da)){
                $retdata  = array();
            }else{
                $retdata  = $da;
            }
            if ($data == true) {
                return json::json('success', '搜索内容获取成功', $retdata);
            } else {
                return json::json('failure', '您搜索的内容不存',[]);
            }
        }
    }

}